package codeRandomThoughts.Test2383赢得比赛需要的最少训练时长;

public class Solution {
    public int minNumberOfHours(int initialEnergy, int initialExperience, int[] energy, int[] experience) {
        //需要的总能量(就是初始能量)
        int energySum = 1;
        for (int i : energy) {
            energySum += i;
        }
        int energyHour = Math.max(energySum - initialEnergy, 0);

        int expHour = 0;
        int currExp = initialExperience;
        for (int exp : experience) {
            if (currExp > exp) {
                currExp += exp;
            } else {
                expHour += exp + 1 - currExp;
                currExp = exp + 1 + exp;//别忘了还要加上打败对手获得的经验值
            }
        }
        return energyHour + expHour;
    }
}
